<template>
  <div class="AboutUs">
    <div class="top">
      <span class="fh"><van-icon name="arrow-left" @click="fh" /></span>
      <span>关于我们</span>
    </div>
    <div class="mainCenter">
      <div>count：{{ $store.state.count }}</div>
      <button @click="addCount">修改count</button>
      <hr />
      <div>age:{{ age }}</div>
      <!-- 异步检测不到，没有使用actions -->
      <div>年龄：{{$store.state.age}}</div>
      <div>是否成年:{{ $store.getters.isAdult }}</div>
      <button @click="addage">修改age</button>
    </div>
  </div>
</template>

<script>
export default {
  name: "AboutUs",
  data() {
    return {
      age: '',
    };
  },
  methods: {
    fh() {
      this.$router.go(-1);
    },
    addCount() {
      this.$store.commit("maddCount", 2);
    },
    addage() {
        //commit找的是mutations的
      /* this.$store.commit({
        type:"maddage",
        msg:2
      });
      */
      this.age = this.$store.state.age; 
      //派发action==》找的是actions的
      this.$store.dispatch('aAddage')
    },
  },
  created() {
    //    console.log(this.$store.state.age);
    this.age = this.$store.state.age;
    // console.log(this.age);
  },
};
</script>

<style scoped>
* {
  margin: 0;
  padding: 0;
  list-style: none;
  text-decoration: none;
}
.AboutUs {
  height: 100%;
  width: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.mainCenter {
  flex: 1;
  overflow: auto;
}
.top {
  text-align: center;
  line-height: 3rem;
  border-bottom: 2px solid gray;
  position: relative;
  height: 3rem;
}
.fh {
  position: absolute;
  font-size: 20px;
  left: 1rem;
}
</style>